<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="6">
            <a-form-model-item label="首跟时间" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="followTime">
              <j-date placeholder="请选择首跟时间" v-model="model.followTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="项目阶段" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="projectStatus">
              <j-dict-select-tag type="list" v-model="model.projectStatus" dictCode="project_status" placeholder="请选择项目名称" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="项目名称" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="projectName">
              <a-input v-model="model.projectName" placeholder="请输入项目阶段"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="项目属性" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="projectProperties">
              <a-input v-model="model.projectProperties" placeholder="请输入项目属性"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="投资主体名称" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="investmentName">
              <a-input v-model="model.investmentName" placeholder="请输入投资主体名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="是否名企" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="isKnown">
              <j-dict-select-tag type="list" v-model="model.isKnown" dictCode="is_known" placeholder="请输入是否名企" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="名企类型" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="knownType">
              <a-input v-model="model.knownType" placeholder="请输入名企类型"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="拟落落地区域" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="place">
              <a-input v-model="model.place" placeholder="请输入拟落落地区域"  ></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="6">
            <a-form-model-item label="企业属性" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="enterpriseProperties">
              <a-input v-model="model.enterpriseProperties" placeholder="请输入企业属性"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="产业分类" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="ndustrialClassification">
              <a-input v-model="model.ndustrialClassification" placeholder="请输入产业分类"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="具体分类" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="classificationDetail">
              <j-dict-select-tag type="list" v-model="model.classificationDetail" dictCode="classification_detail" placeholder="请输入具体分类" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="区县对接人及联系方式" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="dockingPeople">
              <a-input v-model="model.dockingPeople" placeholder="请输入区县对接人及联系方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="企业联系人及联系方式" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="enterprisePeople">
              <a-input v-model="model.enterprisePeople" placeholder="请输入企业联系人及联系方式"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="线索提供人" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="provider">
              <a-input v-model="model.provider" placeholder="请输入线索提供人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="具体对接人" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="contractPerson">
              <a-input v-model="model.contractPerson" placeholder="请输入具体对接人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="责任部门" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="department">
              <a-input v-model="model.department" placeholder="请输入责任部门"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="分管领导" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="leader">
              <a-input v-model="model.leader" placeholder="请输入分管领导"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="是否上报招商办" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="isSubmit">
              <a-input v-model="model.isSubmit" placeholder="请输入是否上报招商办"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="上报时间" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="submitTime">
              <j-date placeholder="请选择上报时间" v-model="model.submitTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="总投资金额（亿元）" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="totalMouney">
              <a-input-number v-model="model.totalMouney" placeholder="请输入总投资金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="内资金额（亿元）" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="domesticMoney">
              <a-input-number v-model="model.domesticMoney" placeholder="请输入内资金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="外资金额（亿元）" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="foreignMoney">
              <a-input-number v-model="model.foreignMoney" placeholder="请输入外资金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="20">
            <a-form-model-item label="项目内容和规模" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="projectDetail">
              <a-textarea type="textarea" v-model="model.projectDetail" placeholder="请输入项目内容和规模" maxLength="2000" :autosize="{ minRows:10 }"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="20">
            <a-form-model-item label="项目最新进展情况" :labelCol="labelCol" :labelAlign="'left'" :wrapperCol="wrapperCol" prop="progressProgress">
              <a-textarea type="textarea" v-model="model.progressProgress" placeholder="请输入项目最新进展情况" maxLength="2000" :autosize="{ minRows:10 }"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'InvestmentPromotionClueForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 10 },
        },
        wrapperCol: {
          xs: { span: 16 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/org.jeecg.modules.clue/investmentPromotionClue/add",
          edit: "/org.jeecg.modules.clue/investmentPromotionClue/edit",
          queryById: "/org.jeecg.modules.clue/investmentPromotionClue/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>